from core.support import set_cutscene
from core.item import Item
from core.action import Action

class powerpivot(Item):
    def __init__(self):
        Item.__init__(self, "powerpivot")    # do basic initialization for every item
        self.updated_powerpivot= False
        
        # build list of actions
        self.add_action(updatepowerpivot)
    
    def get_description(self):
        return "Power Pivot"
    
    def get_image(self):
        return "PowerPivot.jpg"
# define actions for this item
class updatepowerpivot(Action):
    def __init__(self):
        Action.__init__(self, "update_powerpivot")    # do basic initialization for every action
        self.isItemAction=True
    
    # return description of action (used in label on webpage)
    def get_description(self):
        return "update powerpivot"
    
    # return http method to use when user clicks on this action
    # use "get" if just moving to another room.  if changing something
    # like the state of an inventory item or room then use "post"
    def get_method(self):
        return "post"
    
    # only works in basement. add cutscene
    def do_action(self,game,room,request):
        if room.get_id() == 'DellarocasRoom':
                set_cutscene("You update powerpivot and are able to answer Professor Dellarocas' questions.")
                self.item.updated_powerpivot = True
                room.update_powerpivot()
        else:
            set_cutscene("This is the incorrect place update powerpivot.")
        return
    
    def is_enabled(self):
        if self.item.updated_powerpivot:
            return False
        else:
            return True